package com.Maybe.book.aspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component//组件层
public class TimeAspect {
    @Around("execution(* com.Maybe.book.controller.*.*(..))")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        long begin=System.currentTimeMillis();
        //执行原始方法
        Object result=pjp.proceed();
        long end=System.currentTimeMillis();
        log.info(pjp.getSignature()+"执行耗时:{}",end-begin+"ms");
        return result;


    }

}
